<template>
  <el-tabs v-model="activeName" @tab-click="handleClick">
    <el-tab-pane label="查询条件" name="first">
      <!-- <cs-tree
        :treeData="treeData"
        :isFalseButton="isFalseButton"
        :showTitle="false"
        :showAdd="false"
        @handleNodeClick="handleNodeClick"
        ref="tree"/> -->
        <el-tree
          :data="treeData"
          :props="defaultProps"
          @node-click="handleNodeClick"
        >
        </el-tree>
    </el-tab-pane>
  </el-tabs>
</template>

<script>
import util from '@/utils/util'
import {
  selectRuleGroup
} from '@/api/analysis/intelligent'
export default {
  data() {
    return {
      isFalseButton: false,
      activeName: 'first',
      treeData: [],
      defaultProps: {
        children: 'children',
        label: 'label'
      }
    }
  },
  components: {
  },
  created() {
    this.initTree()
  },
  methods: {
    initTree() {
      selectRuleGroup()
        .then(res => {
          res.data.forEach(element => {
            element.label = element.groupName
          })

          this.treeData = util.formatDataToTree(res.data, 'groupId', 'parentId')
        })
    },
    handleClick(tab, event) {
      // console.log(tab, event)
    },
    // 树节点点击事件
    handleNodeClick(data) {
      this.$emit('handleTreeClick', data)
    }
  }
}
</script>

<style scoped>
.log-tree,.el-tree {
  background: transparent !important;
}
</style>
